package com.example.admin.yuejian_22.Activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.support.v7.app.ActionBar;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Toast;

import com.example.admin.yuejian_22.Fragment.MyFragment;
import com.example.admin.yuejian_22.MainActivity;
import com.example.admin.yuejian_22.R;

public class MysetActivity extends Activity implements View.OnClickListener{
    private ImageButton myset_back;
    private RadioButton button_clean;
    private RadioButton button_yaoqing;
    private RadioButton button_help;
    private RadioButton button_edit;
    private PopupWindow mPopWindow;
    private ImageView yaoqing_wechat;
    private ImageView yaoqing_weixinp;
    private ImageView yaoqing_xinlang;


     View view;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_myset);
        button_edit = (RadioButton) findViewById(R.id.button_edit);
        button_edit.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MysetActivity.this,MysetEditActivity.class);
                startActivity(intent);
            }
        });
        button_help = (RadioButton) findViewById(R.id.button_help);
        button_help.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MysetActivity.this,MysetHelpActivityy.class);
                startActivity(intent);
            }
        });

        button_clean = (RadioButton) findViewById(R.id.button_clean);
        button_clean.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MysetActivity.this,MyCleanActivity.class);
                startActivity(intent);
            }
        });
        myset_back = (ImageButton) findViewById(R.id.myset_back);
        myset_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              finish();
            }
        });
        button_yaoqing = (RadioButton) findViewById(R.id.button_yaoqing);

        button_yaoqing.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showPopupWindow();
            }
        });

    }
    private void showPopupWindow() {
        //设置contentView
        View contentView = LayoutInflater.from(MysetActivity.this).inflate(R.layout.popup_yaoqing, null);
        mPopWindow = new PopupWindow(contentView,
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, true);
        mPopWindow.setContentView(contentView);
        //设置各个控件的点击响应
        yaoqing_wechat = (ImageView) contentView.findViewById(R.id.yaoqing_wechat);
        yaoqing_weixinp = (ImageView) contentView.findViewById(R.id.yaoqing_weixinp);
        yaoqing_xinlang = (ImageView) contentView.findViewById(R.id.yaoqing_xinlang);

        yaoqing_wechat.setOnClickListener(this);
        yaoqing_weixinp.setOnClickListener(this);
        yaoqing_xinlang.setOnClickListener(this);
      // btnCancel.setOnClickListener(this);
        //显示PopupWindow
        View rootview = LayoutInflater.from(MysetActivity.this).inflate(R.layout.activity_myset, null);
        mPopWindow.showAtLocation(rootview, Gravity.BOTTOM, 0, 0);

    }
    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id){
            case R.id.yaoqing_weixinp:{
                Toast.makeText(this,"微信朋友圈",Toast.LENGTH_SHORT).show();
                mPopWindow.dismiss();
            }
            break;
            case R.id.yaoqing_wechat:{
                Toast.makeText(this,"微信",Toast.LENGTH_SHORT).show();
                mPopWindow.dismiss();
            }
            break;
            case R.id.yaoqing_xinlang:{
                Toast.makeText(this,"新浪",Toast.LENGTH_SHORT).show();
                mPopWindow.dismiss();
            }
            break;
        }
    }


    }

